// the compiled Rs-DeltaS relation
// created: March 15, 2021 by Yazhou SUN
// lasted modified: May 06, 2022

double Rs(double rs, bool opt);
double DS(double ds, bool opt);

void rsdsCmpHFCp(){
  const int n = 2;
  double xh[n] = {-30., 30.}, yh[n] = {1.23, 0.4};
  TGraph *gHatch = new TGraph(2, xh, yh);
  gHatch->SetLineColor(kWhite);
  gHatch->SetLineWidth(-3200);
  gHatch->SetFillStyle(3004);
  gHatch->SetFillColor(1);
  gHatch->SetMinimum(0.15); gHatch->SetMaximum(1.3);
  gHatch->SetTitle("");
  TAxis *ax = gHatch->GetXaxis(), *ay = gHatch->GetYaxis();
  ax->SetRangeUser(-30, 24);
  ax->SetTitle("\\DeltaS (MeV)"); ay->SetTitle("R_{s}=\\sigma_{exp}/\\sigma_{th}");
  ax->SetTitleOffset(1.0);

  ax->SetLabelSize(0.05); ax->SetTitleSize(0.05);
  ay->SetLabelSize(0.05); ay->SetTitleSize(0.05);
  ax->SetTitleOffset(0.85); ay->SetTitleOffset(0.95);
  ax->CenterTitle(); ay->CenterTitle();
  gStyle->SetEndErrorSize(9);

  // r0 = HF //
  TGraphErrors *gpHF = new TGraphErrors();
  gpHF->SetPoint(0, -1.796642, 0.488437); gpHF->SetPointError(0, 0., 0.042167); // C12
  gpHF->SetPoint(1, 13.314627, 0.418371); gpHF->SetPointError(1, 0., 0.063210); // C13
  gpHF->SetPoint(2, 12.870917, 0.424864); gpHF->SetPointError(2, 0., 0.028120); // C14
  gpHF->SetPoint(3, 20.136266, 0.431190); gpHF->SetPointError(3, 0., 0.042345); // C15
  gpHF->SetPoint(4, 18.302800, 0.290464); gpHF->SetPointError(4, 0., 0.031742); // C16
  gpHF->SetMarkerStyle(20); gpHF->SetMarkerSize(2);
  gpHF->SetMarkerColor(kRed); gpHF->SetLineColor(kRed);
  gpHF->SetLineWidth(3);

  TLegend *lg = new TLegend(0.505,0.65,0.895,0.86);
  lg->AddEntry(gpHF, "R_{s} for ^{x}C-p from ETF", "p");
  lg->SetBorderSize(0);

  TCanvas *c = new TCanvas("c", "Rs-DeltaS", 800, 600);
  gHatch->Draw("ApC");
  TF1 *fpol1p = new TF1("fpol1p", "pol1", -30., 25.);
  fpol1p->SetLineColor(gpHF->GetLineColor());
  gpHF->Fit("fpol1p");
  gpHF->Draw("samep");
  lg->Draw();

  TPaveText *pt = new TPaveText(-2.739644,0.5468334,-0.3535978,0.609409,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  TText *pt_LaTex = pt->AddText("^{12}C");
  pt->Draw();

  pt = new TPaveText(14.43429,0.4554687,16.74857,0.5153646,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{13}C");
  pt->Draw();

  pt = new TPaveText(9.205714,0.4305121,11.60571,0.4929036,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{14}C");
  pt->Draw();

  pt = new TPaveText(21.46286,0.4517253,23.77714,0.5141168,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{15}C");
  pt->Draw();

  pt = new TPaveText(19.40571,0.2158854,21.72,0.2782769,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{16}C");
  pt->Draw();


  c->Print("rsCmpHFCp.pdf");
  // c->Print("/home/asia/Lab/cnok/cnok/docs/rs22/rsCmpHFC.pdf");
  // c->Print("rsCmp.eps");
} // end the main function
